package com.pianzhu.blockchainemr.controller;

import com.pianzhu.blockchainemr.pojo.EmrDeptDict;
import com.pianzhu.blockchainemr.pojo.EmrHospital;
import com.pianzhu.blockchainemr.pojo.EmrPatMaster;
import com.pianzhu.blockchainemr.pojo.Param.EnrollParam;
import com.pianzhu.blockchainemr.pojo.result.Result;
import com.pianzhu.blockchainemr.service.EnrollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/enroll")
public class EnrollController  {
    @Autowired
    private EnrollService enrollService;

    @PostMapping
    public Result enroll(@RequestBody EnrollParam enrollParam) {
        Boolean success = enrollService.enroll(enrollParam);
        if (success) {
            return Result.success();
        }
        return Result.error("注册失败，未知错误");
    }

    @PostMapping("/patMaster")
    public Result patMaster(@RequestBody EmrPatMaster emrPatMaster) {
        enrollService.savePatMaster(emrPatMaster);
        return Result.success();
    }

    @GetMapping("/getHospitalList")
    public Result getHospitalList() {
        List<EmrHospital> hospitalList = enrollService.getHospitalList();
        return Result.success(hospitalList);
    }

    @GetMapping("/getDeptList")
    public Result getDeptList() {
        List<EmrDeptDict> deptList = enrollService.getDeptList();
        return Result.success(deptList);
    }
}
